<!-- 模态框（Modal）-->
<!--fade-->
{{if flag=='false'}}
	<div class="modal fade" role="dialog" id="myModal">
{{else}}
	<div class="modal fade" role="dialog" id="myModal2">
{{/if}}
		<div class="modal-dialog modal-sm">
			<div class="modal-content">
				<div class="modal_header">
				{{if flag=='false'}}
					<h4 class="modal_title title1">新建文件夹</h4>
					<h4 class="modal_title title2">请为此文件夹输入名称。</h4>
				{{else}}
					<h4 class="modal_title title1">添加内容</h4>
				{{/if}}
				</div>
				<div class="modal_body">
				{{if flag=='false'}}
					<form action="/Folder/addFolder" method="post" class="myForm">
						<input type="text" name="folderName"  autocomplete="off"/><span class="glyphicon glyphicon-remove-sign"></span>
					</form>
				{{else}}
					<form action="/Content/addContent" method="post" class="myForm" id="myForm2">
						<input type="text" name="title" id="" value="{{title}}" style="display: none;" />
						<textarea name="content" rows="14" cols="20" autocomplete="off"></textarea>
					</form>
				{{/if}}
				</div>
				<div class="modal_footer">
					<div class="btn-left">取消</div>
					<div class="btn-right" style="color: #ccc;cursor: text;" data-flag="{{flag}}">存储</div>
				</div>
			</div>
		</div>
	</div>
	<div class="modal fade" role="dialog" id="myModal3">
		<div class="modal-dialog modal-sm">
			<div class="modal-content">
				<div class="modal_header">
					<h4 class="modal_title title1">给文件夹重命名</h4>
					<h4 class="modal_title title2">请为此文件夹输入新名称。</h4>
				</div>
				<div class="modal_body">
					<form class="myForm" action="/Folder/updateFolder" method="post">
						<input type="text" name="oldName" id="oldName" value="" style="display: none;" />
						<input type="text" name="newName"  autocomplete="off"/><span class="glyphicon glyphicon-remove-sign"></span>
					</form>
				</div>
				<div class="modal_footer">
					<div class="btn-left">取消</div>
					<div class="btn-right" style="color: #ccc;cursor: text;" data-flag="{{flag}}">存储</div>
				</div>
			</div>
		</div>
	</div>
</body>

</html>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.js"></script>
<script type="text/javascript">
	// 返回上一页
	$('#goBack').click(function() {
			history.go(-1);
		})
	//点击文本框×号
	$('.modal_body span').click(function() {
		$('.modal_body input[type=text]').val('')
		$('.modal_body input[type=text]').focus();
		saveEvent();

	})
	//文本框输入内容
	$('.modal_body input[type=text]').on('input',function() {
		console.log(222)
		saveEvent($(this));
		//文本内容始终小于15个字
		if($(this).val().length>15)
		{
			$(this).val($(this).val().substr(0,15));
		}
	})
	//文本域输入内容
	$('.modal_body textarea').on('input',function() {
		saveEvent($(this));
	})
//	saveEvent('.modal_body input[type=text]');
//	saveEvent('.modal_body textarea');
	var flag = true;
	//判断存储是否可用
	function saveEvent(ele){
		if($(ele).val()!='' && flag==true){
			flag = false;
			$(".btn-right").css({'color':'#E4AF0A',"cursor":"pointer"});
			//存储添加绑定事件
			$('.btn-right').bind('click',function(e){
				if($(this).data('flag'))
				{
					e.preventDefault();
					$.post('/Content/addContent',$('#myForm2').serialize(),function(resData){
						location.reload();
					});
				}
				else
				{
					$(this).parent().prev().find('form').submit();
				}
			});
		}
		if($(ele).val()==''){
			flag = true;
			$(".btn-right").css({'color':'#ccc',"cursor":"text"});
			$('.btn-right').unbind('click');
		}
		
	}
	//点击取消
	$('.modal_footer .btn-left').click(function() {
		$('.modal_body input[type=text]').val('')
		$('.modal_body textarea').val('')
		$('#myModal').modal('hide');
		$('#myModal2').modal('hide');
		$('#myModal3').modal('hide');
	});
</script>